package com.aiyan.edu.framework.domain.gateway.response;

import com.aiyan.edu.framework.model.response.ResultCode;
import com.google.common.collect.ImmutableMap;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author: zqzhou
 * @create: 2019/12/01 19:26
 **/
public enum GatewayCode implements ResultCode {
    ROUTE_NOTFOUND(false, 90001, "未找到路由信息！");

    //操作代码
    @ApiModelProperty(value = "操作是否成功", example = "true", required = true)
    boolean success;

    //操作代码
    @ApiModelProperty(value = "操作代码", example = "22001", required = true)
    int code;
    //提示信息
    @ApiModelProperty(value = "操作提示", example = "操作过于频繁！", required = true)
    String message;

    private GatewayCode(boolean success, int code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    private static final ImmutableMap<Integer, GatewayCode> CACHE;

    static {
        final ImmutableMap.Builder<Integer, GatewayCode> builder = ImmutableMap.builder();
        for (GatewayCode commonCode : values()) {
            builder.put(commonCode.code(), commonCode);
        }
        CACHE = builder.build();
    }

    @Override
    public boolean success() {
        return success;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }
}
